/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Fine.java
 *
 * Created on May 7, 2011, 2:38:58 PM
 */

package c0907m.group2.aitsm.gui;

import c0907m.group2.aitsm.core.db.*;
import c0907m.group2.aitsm.core.entity.*;
import c0907m.group2.aitsm.core.report.FineReporter;
import c0907m.group2.aitsm.gui.component.DefaultPanel;
import c0907m.group2.aitsm.gui.component.StatusBar;
import c0907m.group2.aitsm.util.Helper;
import c0907m.group2.aitsm.util.Settings;
import net.sf.jasperreports.engine.JRException;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import java.awt.*;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author ISTC
 */
public class Fine extends DefaultPanel {
    public static final String DEFAULT_STATUS = "Edit fine.";
    public final Logger logger = Logger.getLogger(Fine.class.getName());
    private DefaultTableModel dtm;
    private DefaultTableModel sModel;
    private StatusBar statusBar;
    private FineDb fineDb;
    private List<SubjectInfo> allSubjects;
    private List<ClassInfo> allClasses;
    private List<SemesterInfo> semestersInClass;

    public void setStatusBar(StatusBar sb) {
        this.statusBar = sb;
    }

    /**
     * Creates new form Fine
     */
    public Fine() {
        initComponents();
        loadDataToComboBox();
        fineDb = new FineDb();
        dtm = (DefaultTableModel) tblFineList.getModel();
        tblFineListRowSorter();
    }

    @Override
    public void refresh() {
        lblCurrentRate.setText(
                Helper.PROPS.getProperty("minRate")
                        + "% - " +
                        Helper.PROPS.getProperty("maxRate")
                        + "%");
        lblCurrentFine.setText(
                Helper.PROPS.getProperty("finePerAbsence")
                        + "$/abs");
        loadFineToTable();
    }

    @Override
    public void doUpdate() {
        for (int i = 0; i < dtm.getRowCount(); i++) {
            FineInfo fi = new FineInfo();
            fi.setStudentId((Integer) dtm.getValueAt(i, 1));
            fi.setSubjectId(allSubjects
                    .get(cboSubject.getSelectedIndex()).getId());
            fi.setSemesterId((Integer) dtm.getValueAt(i, 4));
            fi.setDayTotal((Integer) dtm.getValueAt(i, 6));
            fi.setDayPresent((Integer) dtm.getValueAt(i, 7));
            fi.setDescription("");
            fi.setDailyRate((Double) dtm.getValueAt(i, 9));

            try {
                if ((Integer) dtm.getValueAt(i, 0) == 0) {
                    fineDb.insert(fi);
                } else {
                    fi.setId((Integer) dtm.getValueAt(i, 0));
                    fineDb.update(fi);
                }
            } catch (SQLException ex) {
                logger.log(Level.SEVERE, null, ex);
                statusBar.setMessage("Update failed at row " + i, StatusBar.ERROR_TYPE);
                return;
            }
        }
        statusBar.setMessage("Update successful", StatusBar.MESSAGE_TYPE);
        refresh();
    }

    /**
     * Load all details of all possible fines to table
     */
    private void loadFineToTable() {
        int subjectId;
//        if (cboSubject.getItemAt(0).equals("Select")) {
//            subjectId = allSubjects
//                .get(cboSubject.getSelectedIndex()-1).getId();
//            cboSubject.removeItemAt(0);
//        }
//        else
        subjectId = allSubjects
                .get(cboSubject.getSelectedIndex()).getId();

        dtm = (DefaultTableModel) tblFineList.getModel();
        dtm.setRowCount(0);


        try {

            for (ClassInfo ci : allClasses) {
                List<SemesterInfo> allSemesters = new SemesterDb()
                        .select("", ci.getId(), null, null);

                for (SemesterInfo si : allSemesters) {
                    if (!si.isActive()) continue;
                    FineDb.TotalPresent totalPresent;
                    double rate;
                    double totalFine;

                    for (StudentInfo sti : new StudentDb().select("", si.getClassId())) {
                        if (!sti.isActive()) continue;
                        List<FineInfo> fines = fineDb.select(
                                subjectId,
                                sti.getId(),
                                si.getId());


                        if (!fines.isEmpty()) {
                            for (FineInfo fi : fines) {
                                dtm.addRow(new Object[]{
                                        fi.getId(),
                                        sti.getId(),
                                        sti.getName(),
                                        ci.getName(),
                                        fi.getSemesterId(),
                                        si.getName(),
                                        fi.getDayTotal(),
                                        fi.getDayPresent(),
                                        (double) fi.getDayPresent() / fi.getDayTotal(),
                                        fi.getDailyRate(),
                                        Helper.calculateLevi(
                                                fi.getDayPresent(),
                                                fi.getDayTotal(),
                                                fi.getDailyRate())
                                });
                            }
                        } else {
                            totalPresent = new FineDb().compute(subjectId, si.getId(), sti.getId());
                            if (totalPresent.getTotal() == 0) continue;
                            rate = (float) totalPresent.getPresent() / totalPresent.getTotal();
                            totalFine = Helper.calculateLevi(
                                    totalPresent.getPresent(),
                                    totalPresent.getTotal(),
                                    Double.parseDouble(Helper.PROPS.getProperty("finePerAbsence"))
                            );
                            dtm.addRow(new Object[]{
                                    0,
                                    sti.getId(),
                                    sti.getName(),
                                    ci.getName(),
                                    si.getId(),
                                    si.getName(),
                                    totalPresent.getTotal(),
                                    totalPresent.getPresent(),
                                    rate,
                                    Double.parseDouble(Helper.PROPS.getProperty("finePerAbsence")),
                                    totalFine
                            });
                        }
                    }
                }
            }
            calculateTotal();
        } catch (SQLException ex) {
            Logger.getLogger(Fine.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void addFineListToTable(List<FineInfo> list) {
        dtm = (DefaultTableModel) tblFineList.getModel();
        dtm.setRowCount(0);

        try {
            if (!list.isEmpty()) {
                for (FineInfo fi : list) {
                    dtm.addRow(new Object[]{
                            fi.getId(),
                            fi.getStudentId(),
                            new StudentDb().select(fi.getStudentId()).getName(),
                            new ClassDb().select(new StudentDb().select(fi.getStudentId()).getClassId()).getName(),
                            fi.getSemesterId(),
                            new SemesterDb().select(fi.getSemesterId()).getName(),
                            fi.getDayTotal(),
                            fi.getDayPresent(),
                            (double) fi.getDayPresent() / fi.getDayTotal(),
                            fi.getDailyRate(),
                            Helper.calculateLevi(
                                    fi.getDayPresent(),
                                    fi.getDayTotal(),
                                    fi.getDailyRate())
                    });

                }
            }
        } catch (Exception ex) {
            Logger.getLogger(Fine.class.getName()).log(Level.SEVERE, null, ex);
        }
        calculateTotal();
    }

    /**
     * Calculate total fines from table records
     */
    private void calculateTotal() {
        double total = 0;
        for (int i = 0; i < dtm.getRowCount(); i++) {
            total += (Double) dtm.getValueAt(i, 10);
        }
        lblTotal.setText("" + total);
    }

    /**
     * Save new default fine to config.properties with user's input
     */
    public void saveFine() {
        try {
            double fpa = Double.parseDouble(txtFine.getText());
            Helper.PROPS.setProperty("finePerAbsence", String.valueOf(fpa));
            Helper.saveSettings();
            statusBar.setMessage("New default fine saved.", StatusBar.MESSAGE_TYPE);

            for (int i = 0; i < dtm.getRowCount(); i++) {
                int sessionsToPay = (Integer) dtm.getValueAt(i, 6) - (Integer) dtm.getValueAt(i, 7);
                dtm.setValueAt(fpa, i, 9);
                double maxRate = Double.parseDouble(Helper.PROPS.getProperty("maxRate"));
                double minRate = Double.parseDouble(Helper.PROPS.getProperty("minRate"));
                maxRate /= 100;
                minRate /= 100;
                if ((Double) dtm.getValueAt(i, 8) <= maxRate
                        && (Double) dtm.getValueAt(i, 8) >= minRate) {
                    dtm.setValueAt((double) sessionsToPay * fpa, i, 10);
                }
            }
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "Wrong format!", "Message", JOptionPane.ERROR_MESSAGE);
            statusBar.setMessage("Failed to save rate.", StatusBar.WARNING_TYPE);

        }
    }

    /**
     * Save new default rate to config.properties with user's input
     */
    public void saveRate() {
        try {
            int min = Integer.parseInt(txtMinRate.getText());
            int max = Integer.parseInt(txtMaxRate.getText());

            if (min > max) {
                statusBar.setMessage("Failed to save rate: "
                        + "Min rate must be less than or equal to max rate. ",
                        StatusBar.WARNING_TYPE);
            } else {
                Helper.PROPS.setProperty("minRate", String.valueOf(min));
                Helper.PROPS.setProperty("maxRate", String.valueOf(max));
                Helper.saveSettings();
                statusBar.setMessage("New default rate saved.", StatusBar.MESSAGE_TYPE);
            }

        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "Wrong format!", "Message", JOptionPane.ERROR_MESSAGE);
            statusBar.setMessage("Failed to save rate.", StatusBar.WARNING_TYPE);
        }
    }

    /**
     * Generate items for semester combobox from a selected class
     *
     * @param cboClass    a class to generate semester
     * @param cboSemester target combobox
     */
    private void generateSemester(JComboBox cboClass, JComboBox cboSemester) {
        if (cboSemester.getItemCount() != 0) {
            cboSemester.removeAllItems();
        }
        int classId = allClasses.get(cboClass.getSelectedIndex()).getId();

        try {
            semestersInClass = new SemesterDb().select("", classId, null, null);
            List<SemesterInfo> activeSem = new ArrayList<SemesterInfo>();
            for (SemesterInfo si : semestersInClass) {
                if (si.isActive()) {
                    cboSemester.addItem(si.getName());
                    activeSem.add(si);
                }
            }
            semestersInClass = activeSem;
        } catch (SQLException ex) {
            Logger.getLogger(Fine.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * View report list of fines by semesters
     */
    private void viewSemesterReport() {
        sModel = (DefaultTableModel) tblReportList.getModel();
        if (sModel.getRowCount() == 0) {
            JOptionPane.showMessageDialog(
                    this,
                    "No record to view.",
                    "Warning",
                    JOptionPane.WARNING_MESSAGE
            );
            return;
        }

        List<Integer> smIDs = new ArrayList<Integer>();
        for (int i = 0; i < sModel.getRowCount(); i++) {
            smIDs.add((Integer) sModel.getValueAt(i, 2));
        }

        FineReporter report = new FineReporter();
        report.hasSemesterIds(smIDs);
        try {
            report.view();
        } catch (JRException e) {
            logger.log(Level.WARNING, null, e);
            statusBar.setMessage("Cannot view report.", StatusBar.ERROR_TYPE);
        } catch (SQLException e) {
            logger.log(Level.WARNING, null, e);
            statusBar.setMessage("Cannot view report.", StatusBar.ERROR_TYPE);
        }
    }

    /**
     * View report list of fines by year
     */
    private void viewYearReport() {
        try {
            int year = Integer.parseInt(txtYear.getText());
            FineReporter report = new FineReporter();
            report.hasYear(year);
            report.view();
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(
                    btnViewYearReport,
                    "Wrong format",
                    "Message",
                    JOptionPane.ERROR_MESSAGE);
        } catch (JRException e) {
            logger.log(Level.WARNING, null, e);
            statusBar.setMessage("Cannot view report.", StatusBar.ERROR_TYPE);
        } catch (SQLException e) {
            logger.log(Level.WARNING, null, e);
            statusBar.setMessage("Cannot view report.", StatusBar.ERROR_TYPE);
        }
    }


    /**
     * Search fine records by subject
     *
     * @param sbjId subject ID to search
     */
    private void searchBySubject(int sbjId) {
        dlgSearch.dispose();
        List<FineInfo> result = null;
        try {
            result = fineDb.select(sbjId, 0, 0);
        } catch (SQLException ex) {
            logger.log(Level.SEVERE, null, ex);
        }
        if (result != null) {
            if (!result.isEmpty())
                addFineListToTable(result);
            else
                statusBar.setMessage("No match found.", StatusBar.MESSAGE_TYPE);
        }

    }

    /**
     * Search fine records by student name
     *
     * @param stdName student name to search
     */
    private void searchByStudent(String stdName) {
        dlgSearch.dispose();
        List<FineInfo> result = new ArrayList<FineInfo>();
        try {
            List<StudentInfo> stdList = new StudentDb().select(stdName);
            if (stdList.isEmpty()) {
                statusBar.setMessage("No match found.", StatusBar.MESSAGE_TYPE);
                return;
            }
            for (StudentInfo si : stdList) {
                if (si.isActive()) {
                    List<FineInfo> toAdd = fineDb.select(0, si.getId(), 0);
                    if (!toAdd.isEmpty())
                        result.addAll(toAdd);
                }
            }
        } catch (SQLException e) {
            logger.log(Level.SEVERE, null, e);
        }
        addFineListToTable(result);
        if (dtm.getRowCount() == 0)
            statusBar.setMessage("No match found.", StatusBar.MESSAGE_TYPE);

    }

    /**
     * Search fine records by semester
     *
     * @param sId semester id
     */
    private void searchBySemester(int sId) {
        dlgSearch.dispose();
        List<FineInfo> result = null;
        try {
            result = fineDb.select(0, 0, sId);
            addFineListToTable(result);
        } catch (SQLException e) {
            logger.log(Level.SEVERE, null, e);
        }
        if (result != null) {
            if (dtm.getRowCount() == 0 || result.isEmpty())
                statusBar.setMessage("No match found.", StatusBar.MESSAGE_TYPE);
        }

    }

    /**
     * Load all data to combo box
     */
    private void loadDataToComboBox() {
        try {
            allSubjects = new SubjectDb().select();
            allClasses = new ClassDb().select();

            List<SubjectInfo> activeSbj = new ArrayList<SubjectInfo>();
            for (SubjectInfo s : allSubjects) {
                if (s.isActive()) {
                    cboSubject.addItem(s.getName());
                    cboSubjectSearch.addItem(s.getName());
                    cboSubjectSmtSearch.addItem(s.getName());
                    activeSbj.add(s);
                }
            }
            allSubjects = activeSbj;

            List<ClassInfo> activeClass = new ArrayList<ClassInfo>();
            for (ClassInfo ci : allClasses) {
                if (ci.isActive()) {
                    cboClass.addItem(ci.getName());
                    activeClass.add(ci);
                }
            }
            allClasses = activeClass;

            List<ClassInfo> classesFromSubject = new ArrayList<ClassInfo>();
            cboSubjectSmtSearch.setSelectedIndex(0);
            int sbjId = allSubjects.get(cboSubjectSmtSearch.getSelectedIndex()).getId();
            List<Integer> courseIds = new CourseSubjectDb().select(sbjId, CourseSubjectDb.SUBJECT);
            for (ClassInfo ci : allClasses)
                for (int courseId : courseIds) {
                    if (ci.getCourseId() == courseId) {
                        classesFromSubject.add(ci);
                        cboClassSmtSearch.addItem(ci.getName());
                    }
                }
            generateSemester(cboClassSmtSearch, cboSemesterSearch);
            if (cboSemesterSearch.getItemCount() > 0) cboSemesterSearch.setSelectedIndex(0);
        } catch (SQLException ex) {
            Logger.getLogger(Fine.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Sort a table by column
     */
    private void tblFineListRowSorter() {
        RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(dtm);
        tblFineList.setRowSorter(sorter);
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dlgReport = new javax.swing.JDialog();
        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        btnToggleSemesters = new javax.swing.JButton();
        pnSemesterReport = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        cboClass = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        cboSemester = new javax.swing.JComboBox();
        btnAdd = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        btnRemove = new javax.swing.JButton();
        btnViewSemesterReport = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblReportList = new javax.swing.JTable();
        btnToggleYears = new javax.swing.JButton();
        jLabel19 = new javax.swing.JLabel();
        pnYearReport = new javax.swing.JPanel();
        txtYear = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        btnViewYearReport = new javax.swing.JButton();
        dlgSearch = new javax.swing.JDialog();
        pnReport = new javax.swing.JPanel();
        jLabel21 = new javax.swing.JLabel();
        btnOptionSubject = new javax.swing.JButton();
        pnSearchBySubject = new javax.swing.JPanel();
        cboSubjectSearch = new javax.swing.JComboBox();
        btnSearchBySubject = new javax.swing.JButton();
        btnOptionStudent = new javax.swing.JButton();
        pnSearchByStudent = new javax.swing.JPanel();
        jLabel22 = new javax.swing.JLabel();
        txtStudent = new javax.swing.JTextField();
        btnSearchByStudent = new javax.swing.JButton();
        pnSearchBySemester = new javax.swing.JPanel();
        jLabel24 = new javax.swing.JLabel();
        cboSubjectSmtSearch = new javax.swing.JComboBox();
        jLabel25 = new javax.swing.JLabel();
        cboClassSmtSearch = new javax.swing.JComboBox();
        jLabel26 = new javax.swing.JLabel();
        cboSemesterSearch = new javax.swing.JComboBox();
        btnSearchBySemester = new javax.swing.JButton();
        btnOptionSemester = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        pnFineList = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblFineList = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        lblTotal = new javax.swing.JLabel();
        btnRefresh = new javax.swing.JButton();
        btnReport = new javax.swing.JButton();
        btnUpdate = new javax.swing.JButton();
        pnOptions = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel7 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        lblCurrentRate = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        btnSaveRate = new javax.swing.JButton();
        lblAdvanceSearch = new javax.swing.JLabel();
        jSeparator4 = new javax.swing.JSeparator();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        lblCurrentFine = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        txtFine = new javax.swing.JTextField();
        btnSaveFine = new javax.swing.JButton();
        jLabel12 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        txtMinRate = new javax.swing.JTextField();
        txtMaxRate = new javax.swing.JTextField();
        btnView = new javax.swing.JButton();
        cboSubject = new javax.swing.JComboBox();

        dlgReport.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        dlgReport.setTitle("Report options");
        dlgReport.setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jLabel5.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel5.setText("Select options to view report:");

        jLabel6.setText("Report by semesters");

        btnToggleSemesters.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/dropDown_icon.png"));
        btnToggleSemesters.setContentAreaFilled(false);
        btnToggleSemesters.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToggleSemestersActionPerformed(evt);
            }
        });

        pnSemesterReport.setBackground(new java.awt.Color(255, 255, 255));
        pnSemesterReport.setBorder(javax.swing.BorderFactory.createTitledBorder("View by semesters"));

        jLabel10.setText("Select semester to add to list:");

        jLabel14.setText("Class:");

        cboClass.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboClassActionPerformed(evt);
            }
        });

        jLabel18.setText("Semester:");

        btnAdd.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/add-16.png"));
        btnAdd.setText("Add to list");
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });

        btnRemove.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/delete_btn.png"));
        btnRemove.setText("Remove from list");
        btnRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoveActionPerformed(evt);
            }
        });

        btnViewSemesterReport.setText("View report");
        btnViewSemesterReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewSemesterReportActionPerformed(evt);
            }
        });

        tblReportList.setAutoCreateRowSorter(true);
        tblReportList.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][]{

                },
                new String[]{
                        "Class ID", "Class name", "Semester ID", "Semester name"
                }
        ) {
            Class[] types = new Class[]{
                    java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean[]{
                    false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jScrollPane1.setViewportView(tblReportList);

        javax.swing.GroupLayout pnSemesterReportLayout = new javax.swing.GroupLayout(pnSemesterReport);
        pnSemesterReport.setLayout(pnSemesterReportLayout);
        pnSemesterReportLayout.setHorizontalGroup(
                pnSemesterReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnSemesterReportLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(pnSemesterReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jLabel10)
                                        .addComponent(jSeparator3)
                                        .addGroup(pnSemesterReportLayout.createSequentialGroup()
                                                .addComponent(jLabel14)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(cboClass, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(jLabel18)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(cboSemester, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addComponent(jScrollPane1, 0, 0, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnSemesterReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(btnViewSemesterReport, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE)
                                        .addComponent(btnRemove, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE)))
        );
        pnSemesterReportLayout.setVerticalGroup(
                pnSemesterReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnSemesterReportLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(pnSemesterReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel14)
                                        .addComponent(cboClass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel18)
                                        .addComponent(cboSemester, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(btnAdd))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnSemesterReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(pnSemesterReportLayout.createSequentialGroup()
                                                .addComponent(btnRemove)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addComponent(btnViewSemesterReport))
                                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(28, Short.MAX_VALUE))
        );

        btnToggleYears.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/dropDown_icon.png"));
        btnToggleYears.setContentAreaFilled(false);
        btnToggleYears.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToggleYearsActionPerformed(evt);
            }
        });

        jLabel19.setText("Report by year");

        pnYearReport.setBackground(new java.awt.Color(255, 255, 255));

        jLabel20.setText("Enter a year to view report (format: yyyy):");

        btnViewYearReport.setText("View report");
        btnViewYearReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewYearReportActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnYearReportLayout = new javax.swing.GroupLayout(pnYearReport);
        pnYearReport.setLayout(pnYearReportLayout);
        pnYearReportLayout.setHorizontalGroup(
                pnYearReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnYearReportLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(pnYearReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(pnYearReportLayout.createSequentialGroup()
                                                .addComponent(txtYear, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(btnViewYearReport))
                                        .addComponent(jLabel20))
                                .addContainerGap(329, Short.MAX_VALUE))
        );
        pnYearReportLayout.setVerticalGroup(
                pnYearReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnYearReportLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel20)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnYearReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(txtYear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(btnViewYearReport))
                                .addContainerGap(52, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addContainerGap()
                                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(jLabel5)
                                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                                                .addGap(10, 10, 10)
                                                                .addComponent(btnToggleSemesters, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(jLabel6))))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addGap(18, 18, 18)
                                                .addComponent(btnToggleYears, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(jLabel19)))
                                .addContainerGap(393, Short.MAX_VALUE))
                        .addComponent(pnYearReport, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(pnSemesterReport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
                jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(btnToggleSemesters, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel6))
                                .addGap(18, 18, 18)
                                .addComponent(pnSemesterReport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(btnToggleYears, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel19))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pnYearReport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap())
        );

        pnSemesterReport.setVisible(false);
        pnYearReport.setVisible(false);

        javax.swing.GroupLayout dlgReportLayout = new javax.swing.GroupLayout(dlgReport.getContentPane());
        dlgReport.getContentPane().setLayout(dlgReportLayout);
        dlgReportLayout.setHorizontalGroup(
                dlgReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        dlgReportLayout.setVerticalGroup(
                dlgReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        dlgSearch.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        pnReport.setBackground(new java.awt.Color(255, 255, 255));

        jLabel21.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel21.setText("Select option to search:");

        btnOptionSubject.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/dropDown_icon.png"));
        btnOptionSubject.setText("Search by subject");
        btnOptionSubject.setContentAreaFilled(false);
        btnOptionSubject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOptionSubjectActionPerformed(evt);
            }
        });

        pnSearchBySubject.setBackground(new java.awt.Color(255, 255, 255));

        btnSearchBySubject.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/search-16.png"));
        btnSearchBySubject.setText("Search");
        btnSearchBySubject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchBySubjectActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnSearchBySubjectLayout = new javax.swing.GroupLayout(pnSearchBySubject);
        pnSearchBySubject.setLayout(pnSearchBySubjectLayout);
        pnSearchBySubjectLayout.setHorizontalGroup(
                pnSearchBySubjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnSearchBySubjectLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(cboSubjectSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnSearchBySubject)
                                .addContainerGap(264, Short.MAX_VALUE))
        );
        pnSearchBySubjectLayout.setVerticalGroup(
                pnSearchBySubjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnSearchBySubjectLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(pnSearchBySubjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(cboSubjectSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(btnSearchBySubject))
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnOptionStudent.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/dropDown_icon.png"));
        btnOptionStudent.setText("Search by student");
        btnOptionStudent.setContentAreaFilled(false);
        btnOptionStudent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOptionStudentActionPerformed(evt);
            }
        });

        pnSearchByStudent.setBackground(new java.awt.Color(255, 255, 255));

        jLabel22.setText("Student name:");

        btnSearchByStudent.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/search-16.png"));
        btnSearchByStudent.setText("Search");
        btnSearchByStudent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchByStudentActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnSearchByStudentLayout = new javax.swing.GroupLayout(pnSearchByStudent);
        pnSearchByStudent.setLayout(pnSearchByStudentLayout);
        pnSearchByStudentLayout.setHorizontalGroup(
                pnSearchByStudentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnSearchByStudentLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel22)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnSearchByStudentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(btnSearchByStudent)
                                        .addComponent(txtStudent, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(183, Short.MAX_VALUE))
        );
        pnSearchByStudentLayout.setVerticalGroup(
                pnSearchByStudentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnSearchByStudentLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(pnSearchByStudentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel22)
                                        .addComponent(txtStudent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnSearchByStudent)
                                .addContainerGap(23, Short.MAX_VALUE))
        );

        pnSearchBySemester.setBackground(new java.awt.Color(255, 255, 255));

        jLabel24.setText("Subject:");

        cboSubjectSmtSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboSubjectSmtSearchActionPerformed(evt);
            }
        });

        jLabel25.setText("Class:");

        cboClassSmtSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cboClassSmtSearchActionPerformed(evt);
            }
        });

        jLabel26.setText("Semester:");

        btnSearchBySemester.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/search-16.png"));
        btnSearchBySemester.setText("Search");
        btnSearchBySemester.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSearchBySemesterActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnSearchBySemesterLayout = new javax.swing.GroupLayout(pnSearchBySemester);
        pnSearchBySemester.setLayout(pnSearchBySemesterLayout);
        pnSearchBySemesterLayout.setHorizontalGroup(
                pnSearchBySemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnSearchBySemesterLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(pnSearchBySemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(pnSearchBySemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(pnSearchBySemesterLayout.createSequentialGroup()
                                                        .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE))
                                                .addComponent(jLabel25, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE))
                                        .addComponent(jLabel26))
                                .addGroup(pnSearchBySemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(cboSubjectSmtSearch, 0, 96, Short.MAX_VALUE)
                                        .addComponent(cboClassSmtSearch, 0, 96, Short.MAX_VALUE)
                                        .addGroup(pnSearchBySemesterLayout.createSequentialGroup()
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addGroup(pnSearchBySemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(btnSearchBySemester)
                                                        .addComponent(cboSemesterSearch, 0, 96, Short.MAX_VALUE))))
                                .addGap(258, 258, 258))
        );
        pnSearchBySemesterLayout.setVerticalGroup(
                pnSearchBySemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnSearchBySemesterLayout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addGroup(pnSearchBySemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(cboSubjectSmtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel24))
                                .addGap(18, 18, 18)
                                .addGroup(pnSearchBySemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(cboClassSmtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel25))
                                .addGap(18, 18, 18)
                                .addGroup(pnSearchBySemesterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel26)
                                        .addComponent(cboSemesterSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnSearchBySemester)
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        btnOptionSemester.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/dropDown_icon.png"));
        btnOptionSemester.setText("Search by semester");
        btnOptionSemester.setContentAreaFilled(false);
        btnOptionSemester.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOptionSemesterActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnReportLayout = new javax.swing.GroupLayout(pnReport);
        pnReport.setLayout(pnReportLayout);
        pnReportLayout.setHorizontalGroup(
                pnReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnReportLayout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addGroup(pnReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(pnSearchBySubject, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(pnSearchByStudent, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(pnReportLayout.createSequentialGroup()
                                                .addComponent(btnOptionSubject, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addContainerGap())
                                        .addGroup(pnReportLayout.createSequentialGroup()
                                                .addComponent(btnOptionStudent, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addContainerGap())))
                        .addGroup(pnReportLayout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel21)
                                .addContainerGap(319, Short.MAX_VALUE))
                        .addGroup(pnReportLayout.createSequentialGroup()
                                .addGap(20, 20, 20)
                                .addGroup(pnReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(pnReportLayout.createSequentialGroup()
                                                .addComponent(btnOptionSemester, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addContainerGap())
                                        .addComponent(pnSearchBySemester, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        pnReportLayout.setVerticalGroup(
                pnReportLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnReportLayout.createSequentialGroup()
                                .addGap(16, 16, 16)
                                .addComponent(jLabel21)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnOptionSubject)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pnSearchBySubject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnOptionStudent)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pnSearchByStudent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnOptionSemester)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(pnSearchBySemester, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
        );

        pnSearchBySubject.setVisible(false);
        pnSearchByStudent.setVisible(false);
        pnSearchBySemester.setVisible(false);

        javax.swing.GroupLayout dlgSearchLayout = new javax.swing.GroupLayout(dlgSearch.getContentPane());
        dlgSearch.getContentPane().setLayout(dlgSearchLayout);
        dlgSearchLayout.setHorizontalGroup(
                dlgSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(pnReport, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        dlgSearchLayout.setVerticalGroup(
                dlgSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(pnReport, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        setBackground(new java.awt.Color(255, 255, 255));

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 16));
        jLabel4.setForeground(new java.awt.Color(0, 102, 255));
        jLabel4.setText("MANAGE FINE");

        pnFineList.setBackground(new java.awt.Color(255, 255, 255));
        pnFineList.setBorder(javax.swing.BorderFactory.createTitledBorder("Fine list"));

        tblFineList.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][]{

                },
                new String[]{
                        "Fine ID", "Student ID", "Student name", "Class", "Semester ID", "Semester name", "Total sessions", "Presence", "Percentage", "Rate", "Total fine"
                }
        ) {
            Class[] types = new Class[]{
                    java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Double.class, java.lang.Double.class, java.lang.Double.class
            };
            boolean[] canEdit = new boolean[]{
                    false, false, false, false, false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        });
        jScrollPane2.setViewportView(tblFineList);
        tblFineList.getColumnModel().getColumn(0).setPreferredWidth(40);
        tblFineList.getColumnModel().getColumn(1).setPreferredWidth(60);
        tblFineList.getColumnModel().getColumn(2).setPreferredWidth(80);
        tblFineList.getColumnModel().getColumn(7).setPreferredWidth(50);
        tblFineList.getColumnModel().getColumn(9).setPreferredWidth(40);
        tblFineList.getColumnModel().getColumn(10).setPreferredWidth(60);

        jLabel3.setFont(new java.awt.Font("Tahoma", 3, 13));
        jLabel3.setText("Total:");

        lblTotal.setFont(new java.awt.Font("Tahoma", 0, 13));
        lblTotal.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);

        javax.swing.GroupLayout pnFineListLayout = new javax.swing.GroupLayout(pnFineList);
        pnFineList.setLayout(pnFineListLayout);
        pnFineListLayout.setHorizontalGroup(
                pnFineListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnFineListLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(pnFineListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 847, Short.MAX_VALUE)
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnFineListLayout.createSequentialGroup()
                                                .addComponent(jLabel3)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(lblTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addContainerGap())
        );
        pnFineListLayout.setVerticalGroup(
                pnFineListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnFineListLayout.createSequentialGroup()
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                                .addGroup(pnFineListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(lblTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel3)))
        );

        btnRefresh.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/refresh-16.gif"));
        btnRefresh.setText("Refresh");
        btnRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefreshActionPerformed(evt);
            }
        });

        btnReport.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/printer-16.png"));
        btnReport.setText("Report");
        btnReport.setMaximumSize(new java.awt.Dimension(71, 23));
        btnReport.setMinimumSize(new java.awt.Dimension(71, 23));
        btnReport.setPreferredSize(new java.awt.Dimension(71, 23));
        btnReport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnReportActionPerformed(evt);
            }
        });

        btnUpdate.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/update-16.png"));
        btnUpdate.setText("Update");
        btnUpdate.setMaximumSize(new java.awt.Dimension(71, 23));
        btnUpdate.setMinimumSize(new java.awt.Dimension(71, 23));
        btnUpdate.setPreferredSize(new java.awt.Dimension(71, 23));
        btnUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdateActionPerformed(evt);
            }
        });

        pnOptions.setBackground(new java.awt.Color(255, 255, 255));
        pnOptions.setBorder(javax.swing.BorderFactory.createTitledBorder("Options"));
        pnOptions.setPreferredSize(new java.awt.Dimension(452, 219));

        jLabel1.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel1.setText("Select subject to display list of students' fine:");

        jLabel2.setText("Subject:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel7.setText("Set max percentage and min percentage to calculate fine:");

        jLabel13.setText("Current rate (to be levied):");

        lblCurrentRate.setText(Helper.PROPS.getProperty("minRate") + "% - " + Helper.PROPS.getProperty("maxRate") + "%");

        jLabel15.setText("New rate:");

        jLabel16.setText("% - ");

        jLabel17.setText("%");

        btnSaveRate.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/save_btn.gif"));
        btnSaveRate.setText("Save");
        btnSaveRate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveRateActionPerformed(evt);
            }
        });

        lblAdvanceSearch.setForeground(new java.awt.Color(0, 0, 255));
        lblAdvanceSearch.setText("Search for fine records");
        lblAdvanceSearch.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        lblAdvanceSearch.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblAdvanceSearchMouseClicked(evt);
            }
        });

        jSeparator4.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel8.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel8.setText("Set default rate:");

        jLabel9.setText("Current rate:");

        lblCurrentFine.setText(Helper.PROPS.getProperty("finePerAbsence") + "$/abs");

        jLabel11.setText("New rate:");

        btnSaveFine.setIcon(new ImageIcon(Settings.IMAGES_DIR + "/save_btn.gif"));
        btnSaveFine.setText("Save");
        btnSaveFine.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveFineActionPerformed(evt);
            }
        });

        jLabel12.setText("$/abs");

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);

        btnView.setText("View");
        btnView.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnOptionsLayout = new javax.swing.GroupLayout(pnOptions);
        pnOptions.setLayout(pnOptionsLayout);
        pnOptionsLayout.setHorizontalGroup(
                pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                                .addComponent(jLabel13)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(lblCurrentRate))
                                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                                .addComponent(jLabel15)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(txtMinRate, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(jLabel16)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(txtMaxRate, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(jLabel17)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                .addComponent(btnSaveRate))
                                                        .addComponent(jLabel7))
                                                .addGap(108, 108, 108)
                                                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(55, 55, 55)
                                                .addComponent(lblAdvanceSearch)
                                                .addContainerGap())
                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(jLabel1)
                                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                                .addComponent(jLabel2)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(cboSubject, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(btnView)))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 167, Short.MAX_VALUE)
                                                .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(56, 56, 56)
                                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(jLabel8)
                                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                                .addComponent(jLabel9)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(lblCurrentFine)
                                                                .addGap(18, 18, 18)
                                                                .addComponent(jLabel11)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(txtFine, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addComponent(jLabel12)
                                                                .addGap(18, 18, 18)
                                                                .addComponent(btnSaveFine)))
                                                .addGap(47, 47, 47))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOptionsLayout.createSequentialGroup()
                                                .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 850, Short.MAX_VALUE)
                                                .addContainerGap())))
        );
        pnOptionsLayout.setVerticalGroup(
                pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnOptionsLayout.createSequentialGroup()
                                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                .addComponent(jLabel1)
                                                .addGap(18, 18, 18)
                                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(jLabel2)
                                                        .addComponent(btnView)
                                                        .addComponent(cboSubject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                .addComponent(jLabel8)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(jLabel9)
                                                        .addComponent(lblCurrentFine)
                                                        .addComponent(jLabel11)
                                                        .addComponent(txtFine, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(jLabel12)
                                                        .addComponent(btnSaveFine)))
                                        .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(11, 11, 11)
                                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                .addGap(25, 25, 25)
                                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                                .addComponent(jLabel7)
                                                                .addGap(18, 18, 18)
                                                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                                        .addComponent(jLabel13)
                                                                        .addComponent(lblCurrentRate))
                                                                .addGap(18, 18, 18)
                                                                .addGroup(pnOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                                        .addComponent(jLabel15)
                                                                        .addComponent(jLabel16)
                                                                        .addComponent(txtMinRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(txtMaxRate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(jLabel17)
                                                                        .addComponent(btnSaveRate)))))
                                        .addGroup(pnOptionsLayout.createSequentialGroup()
                                                .addGap(18, 18, 18)
                                                .addComponent(lblAdvanceSearch)))
                                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup()
                                                .addGap(24, 24, 24)
                                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(jLabel4)
                                                        .addComponent(pnOptions, javax.swing.GroupLayout.PREFERRED_SIZE, 886, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGroup(layout.createSequentialGroup()
                                                .addGap(359, 359, 359)
                                                .addComponent(btnUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(btnRefresh, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(btnReport, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addContainerGap(29, Short.MAX_VALUE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                        .addGap(26, 26, 26)
                                        .addComponent(pnFineList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addContainerGap(30, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addGap(25, 25, 25)
                                .addComponent(jLabel4)
                                .addGap(267, 267, 267)
                                .addComponent(pnOptions, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(btnUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(btnRefresh, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(btnReport, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addContainerGap(26, Short.MAX_VALUE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                        .addGap(60, 60, 60)
                                        .addComponent(pnFineList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addContainerGap(306, Short.MAX_VALUE)))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshActionPerformed
        refresh();
    }//GEN-LAST:event_btnRefreshActionPerformed

    private void btnReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnReportActionPerformed
        dlgReport = new JDialog();
        dlgReport.setContentPane(jPanel1);
        dlgReport.setPreferredSize(new Dimension(550, 630));
        dlgReport.setResizable(false);
        dlgReport.pack();
        dlgReport.setVisible(true);
    }//GEN-LAST:event_btnReportActionPerformed

    private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateActionPerformed
        doUpdate();
    }//GEN-LAST:event_btnUpdateActionPerformed

    private void btnSaveRateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveRateActionPerformed
        saveRate();
    }//GEN-LAST:event_btnSaveRateActionPerformed

    private void lblAdvanceSearchMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblAdvanceSearchMouseClicked
        dlgSearch = new JDialog();
        dlgSearch.setContentPane(pnReport);
        dlgSearch.setPreferredSize(new Dimension(450, 500));
        dlgSearch.setLocationRelativeTo(null);
        dlgSearch.pack();
        dlgSearch.setVisible(true);
    }//GEN-LAST:event_lblAdvanceSearchMouseClicked

    private void btnSaveFineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveFineActionPerformed
        saveFine();
    }//GEN-LAST:event_btnSaveFineActionPerformed

    private void btnViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewActionPerformed
        loadFineToTable();
    }//GEN-LAST:event_btnViewActionPerformed

    private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddActionPerformed
        sModel = (DefaultTableModel) tblReportList.getModel();
        sModel.addRow(new Object[]{
                allClasses.get(cboClass.getSelectedIndex()).getId(),
                (String) cboClass.getSelectedItem(),
                semestersInClass.get(cboSemester.getSelectedIndex()).getId(),
                (String) cboSemester.getSelectedItem()
        });
    }//GEN-LAST:event_btnAddActionPerformed

    private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveActionPerformed
        if (tblReportList.getSelectedRow() == -1) {
            statusBar.setMessage("No row selected", StatusBar.WARNING_TYPE);
            return;
        }
        sModel = (DefaultTableModel) tblReportList.getModel();
        sModel.removeRow(tblReportList.getSelectedRow());
    }//GEN-LAST:event_btnRemoveActionPerformed

    private void btnViewSemesterReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewSemesterReportActionPerformed
        viewSemesterReport();
        dlgReport.dispose();
    }//GEN-LAST:event_btnViewSemesterReportActionPerformed

    private void btnViewYearReportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewYearReportActionPerformed
        viewYearReport();
        dlgReport.dispose();
    }//GEN-LAST:event_btnViewYearReportActionPerformed

    private void btnToggleSemestersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToggleSemestersActionPerformed
        Helper.toggle(pnSemesterReport);
    }//GEN-LAST:event_btnToggleSemestersActionPerformed

    private void btnToggleYearsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToggleYearsActionPerformed
        Helper.toggle(pnYearReport);
    }//GEN-LAST:event_btnToggleYearsActionPerformed

    private void cboClassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboClassActionPerformed
        generateSemester(cboClass, cboSemester);
    }//GEN-LAST:event_cboClassActionPerformed

    private void btnOptionSubjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOptionSubjectActionPerformed
        Helper.toggle(pnSearchBySubject);
    }//GEN-LAST:event_btnOptionSubjectActionPerformed

    private void btnOptionStudentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOptionStudentActionPerformed
        Helper.toggle(pnSearchByStudent);
    }//GEN-LAST:event_btnOptionStudentActionPerformed

    private void btnOptionSemesterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOptionSemesterActionPerformed
        Helper.toggle(pnSearchBySemester);
    }//GEN-LAST:event_btnOptionSemesterActionPerformed

    private void btnSearchBySubjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchBySubjectActionPerformed
        dlgSearch.setVisible(false);
        int sbjId = allSubjects.get(cboSubjectSearch.getSelectedIndex()).getId();
        searchBySubject(sbjId);
        dlgSearch.dispose();
    }//GEN-LAST:event_btnSearchBySubjectActionPerformed

    private void btnSearchByStudentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchByStudentActionPerformed
        dlgSearch.setVisible(false);
        String stdName = txtStudent.getText();
        searchByStudent(stdName);
        dlgSearch.dispose();
    }//GEN-LAST:event_btnSearchByStudentActionPerformed

    private void btnSearchBySemesterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSearchBySemesterActionPerformed
        dlgSearch.setVisible(false);
        int smId = semestersInClass.get(cboSemesterSearch.getSelectedIndex()).getId();
        searchBySemester(smId);
        dlgSearch.dispose();
    }//GEN-LAST:event_btnSearchBySemesterActionPerformed

    private void cboSubjectSmtSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboSubjectSmtSearchActionPerformed

    }//GEN-LAST:event_cboSubjectSmtSearchActionPerformed

    private void cboClassSmtSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cboClassSmtSearchActionPerformed
        if (cboSemesterSearch.getSelectedIndex() == -1)
            return;
        generateSemester(cboClassSmtSearch, cboSemesterSearch);
    }//GEN-LAST:event_cboClassSmtSearchActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdd;
    private javax.swing.JButton btnOptionSemester;
    private javax.swing.JButton btnOptionStudent;
    private javax.swing.JButton btnOptionSubject;
    private javax.swing.JButton btnRefresh;
    private javax.swing.JButton btnRemove;
    private javax.swing.JButton btnReport;
    private javax.swing.JButton btnSaveFine;
    private javax.swing.JButton btnSaveRate;
    private javax.swing.JButton btnSearchBySemester;
    private javax.swing.JButton btnSearchByStudent;
    private javax.swing.JButton btnSearchBySubject;
    private javax.swing.JButton btnToggleSemesters;
    private javax.swing.JButton btnToggleYears;
    private javax.swing.JButton btnUpdate;
    private javax.swing.JButton btnView;
    private javax.swing.JButton btnViewSemesterReport;
    private javax.swing.JButton btnViewYearReport;
    private javax.swing.JComboBox cboClass;
    private javax.swing.JComboBox cboClassSmtSearch;
    private javax.swing.JComboBox cboSemester;
    private javax.swing.JComboBox cboSemesterSearch;
    private javax.swing.JComboBox cboSubject;
    private javax.swing.JComboBox cboSubjectSearch;
    private javax.swing.JComboBox cboSubjectSmtSearch;
    private javax.swing.JDialog dlgReport;
    private javax.swing.JDialog dlgSearch;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JLabel lblAdvanceSearch;
    private javax.swing.JLabel lblCurrentFine;
    private javax.swing.JLabel lblCurrentRate;
    private javax.swing.JLabel lblTotal;
    private javax.swing.JPanel pnFineList;
    private javax.swing.JPanel pnOptions;
    private javax.swing.JPanel pnReport;
    private javax.swing.JPanel pnSearchBySemester;
    private javax.swing.JPanel pnSearchByStudent;
    private javax.swing.JPanel pnSearchBySubject;
    private javax.swing.JPanel pnSemesterReport;
    private javax.swing.JPanel pnYearReport;
    private javax.swing.JTable tblFineList;
    private javax.swing.JTable tblReportList;
    private javax.swing.JTextField txtFine;
    private javax.swing.JTextField txtMaxRate;
    private javax.swing.JTextField txtMinRate;
    private javax.swing.JTextField txtStudent;
    private javax.swing.JTextField txtYear;
    // End of variables declaration//GEN-END:variables

}
